package org.jeeasy.ai.controller;

import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.jeeasy.common.core.domain.vo.R;
import org.springframework.ai.ollama.api.OllamaApi;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Slf4j
@RestController
@RequestMapping("/ai/ollama")
@RequiredArgsConstructor
public class OllamaController {
    private final OllamaApi ollamaApi;

    /**
     * 获取模型列表
     *
     * @return
     */
    @GetMapping("/models")
    public R<List<OllamaApi.Model>> getModels() {
        OllamaApi.ListModelResponse listModelResponse = ollamaApi.listModels();
        return R.ok(listModelResponse.models());
    }
}
